//
//  XRPlayerView.m
//  avplayer
//
//  Created by 谢汝 on 2017/12/18.
//  Copyright © 2017年 谢汝. All rights reserved.
//

#import "XRPlayerView.h"
#import <AVFoundation/AVFoundation.h>


@interface XRPlayerView () {
    AVPlayerLayer *_playerLayer;
}
@end
@implementation XRPlayerView

- (instancetype)initWithMoviePlayerLayer:(AVPlayerLayer *)playerLayer frame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        _playerLayer = playerLayer;
        _playerLayer.backgroundColor = [UIColor blackColor].CGColor;
        _playerLayer.videoGravity = AVLayerVideoGravityResizeAspect;
        _playerLayer.contentsScale = [UIScreen mainScreen].scale;
        [self.layer addSublayer:_playerLayer];
    }
    return self;
}


- (void)layoutSublayersOfLayer:(CALayer *)layer {
    [super layoutSublayersOfLayer:layer];
    
    _playerLayer.bounds = self.layer.bounds;
    _playerLayer.position = self.layer.position;
}





@end
